package com.yc.cloud.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yc.cloud.entity.HwDeviceGroupStrategy;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 设备分组与策略关联表 Mapper 接口
 * </p>
 *
 * @author kinggu
 * @since 2025-07-15
 */
public interface HwDeviceGroupStrategyMapper extends BaseMapper<HwDeviceGroupStrategy> {

    /**
     * 根据设备分组ID查询关联的策略ID列表
     *
     * @param groupId 设备分组ID
     * @return 策略ID列表
     */
    default List<Long> selectStrategyIdsByGroupId(Long groupId) {
        return this.selectList(
            new QueryWrapper<HwDeviceGroupStrategy>().eq(HwDeviceGroupStrategy.GroupId, groupId)
        ).stream().map(HwDeviceGroupStrategy::getStrategyId).collect(Collectors.toList());
    }
}
